function residual = dynamic_resid(T, y, x, params, steady_state, it_, T_flag)
% function residual = dynamic_resid(T, y, x, params, steady_state, it_, T_flag)
%
% File created by Dynare Preprocessor from .mod file
%
% Inputs:
%   T             [#temp variables by 1]     double   vector of temporary terms to be filled by function
%   y             [#dynamic variables by 1]  double   vector of endogenous variables in the order stored
%                                                     in M_.lead_lag_incidence; see the Manual
%   x             [nperiods by M_.exo_nbr]   double   matrix of exogenous variables (in declaration order)
%                                                     for all simulation periods
%   steady_state  [M_.endo_nbr by 1]         double   vector of steady state values
%   params        [M_.param_nbr by 1]        double   vector of parameter values in declaration order
%   it_           scalar                     double   time period for exogenous variables for which
%                                                     to evaluate the model
%   T_flag        boolean                    boolean  flag saying whether or not to calculate temporary terms
%
% Output:
%   residual
%

if T_flag
    T = model_file.dynamic_resid_tt(T, y, x, params, steady_state, it_);
end
residual = zeros(97, 1);
lhs = y(23)^T(2);
rhs = 1-params(1)+params(1)*y(24)^T(2);
residual(1) = lhs - rhs;
lhs = y(24)^(1-params(3));
rhs = (y(120)*exp(y(127)))^(1-params(3));
residual(2) = lhs - rhs;
lhs = y(27);
rhs = T(6)*T(9);
residual(3) = lhs - rhs;
lhs = y(29)^T(10);
rhs = params(9)*y(30)^T(10)+(1-params(9))*exp(T(10)*y(49))*T(11);
residual(4) = lhs - rhs;
lhs = y(25);
rhs = y(27)*y(9)/y(39);
residual(5) = lhs - rhs;
lhs = y(36)/y(39);
rhs = params(5)*T(12)^T(3);
residual(6) = lhs - rhs;
lhs = y(28);
rhs = T(13)*T(14)*T(15);
residual(7) = lhs - rhs;
lhs = y(30)+y(32)+y(68);
rhs = y(28);
residual(8) = lhs - rhs;
lhs = y(33)*exp(y(47));
rhs = y(7)*(1-params(13))+y(7)*y(62);
residual(9) = lhs - rhs;
lhs = y(62);
rhs = T(17)*T(18)^T(16)+params(19);
residual(10) = lhs - rhs;
lhs = exp(y(35));
rhs = T(19)*T(21);
residual(11) = lhs - rhs;
lhs = y(64);
rhs = y(28)*params(12)*(1-1/params(11))/y(7);
residual(12) = lhs - rhs;
lhs = y(66);
rhs = (-T(22))/y(7);
residual(13) = lhs - rhs;
lhs = y(63);
rhs = params(18)*T(18)^T(23);
residual(14) = lhs - rhs;
lhs = y(121)*exp(y(122));
rhs = 1;
residual(15) = lhs - rhs;
lhs = y(45)*y(63);
rhs = 1;
residual(16) = lhs - rhs;
residual(17) = y(65)-y(36)-y(44)*y(67);
lhs = y(65);
rhs = y(28)*T(24)/y(34);
residual(18) = lhs - rhs;
lhs = y(67);
rhs = (-T(25))/y(34);
residual(19) = lhs - rhs;
residual(20) = y(44)+(-y(69))-exp(y(47))*y(121)*y(129);
lhs = y(68);
rhs = y(28)*T(27);
residual(21) = lhs - rhs;
lhs = y(69);
rhs = y(28)*exp(y(37)-params(44))*params(14)*(exp(y(37)-params(44))-1);
residual(22) = lhs - rhs;
lhs = y(70);
rhs = y(28)*exp(y(37)-params(44))*(exp(y(37)-params(44))-1)*(-params(14));
residual(23) = lhs - rhs;
lhs = T(28)*exp(y(38));
rhs = 1;
residual(24) = lhs - rhs;
lhs = y(38)-params(45);
rhs = params(40)*(y(8)-params(45))+(y(37)-params(44))*(1-params(40))*params(41)+(1-params(40))*params(42)*log(T(29))+params(43)*x(it_, 2);
residual(25) = lhs - rhs;
lhs = T(30);
rhs = 1;
residual(26) = lhs - rhs;
lhs = y(40);
rhs = T(33)*T(35);
residual(27) = lhs - rhs;
lhs = y(29)*y(39);
rhs = y(30)+y(50)*y(40);
residual(28) = lhs - rhs;
lhs = y(42);
rhs = y(37)+log(y(40))-log(y(10));
residual(29) = lhs - rhs;
lhs = y(41);
rhs = y(37)+log(y(39))-log(y(9));
residual(30) = lhs - rhs;
lhs = exp(y(43));
rhs = exp(y(37))*(1+y(40))/(1+y(10));
residual(31) = lhs - rhs;
lhs = y(51);
rhs = log(y(125))-log(y(40));
residual(32) = lhs - rhs;
lhs = y(46);
rhs = (1-params(24))*params(25)+params(24)*y(12)+params(23)*params(27)*exp(y(14))*x(it_, 1);
residual(33) = lhs - rhs;
lhs = y(47);
rhs = (1-params(16))*params(8)+params(16)*y(13)+x(it_, 1)*exp(y(14))*params(27)*params(17);
residual(34) = lhs - rhs;
lhs = log(y(50));
rhs = (1-params(35))*log(params(48))+params(35)*log(y(16))+T(36)*x(it_, 3);
residual(35) = lhs - rhs;
lhs = y(52);
rhs = y(15);
residual(36) = lhs - rhs;
lhs = y(49);
rhs = y(15)*params(36)+params(37)*y(17)+params(34)*x(it_, 4)+x(it_, 1)*params(38);
residual(37) = lhs - rhs;
lhs = y(48);
rhs = y(14)*params(26)+params(28)*x(it_, 6)-x(it_, 1)*params(27)*params(30);
residual(38) = lhs - rhs;
lhs = y(72);
rhs = y(28)-y(36)*y(34)-y(32)-y(68);
residual(39) = lhs - rhs;
lhs = y(73);
rhs = y(72)+y(50)*y(40)*params(39);
residual(40) = lhs - rhs;
lhs = y(74);
rhs = y(13)+log(y(72))-log(y(19));
residual(41) = lhs - rhs;
lhs = y(76);
rhs = y(37)+y(74)-y(43);
residual(42) = lhs - rhs;
lhs = y(75);
rhs = y(43)+y(76);
residual(43) = lhs - rhs;
lhs = y(77);
rhs = y(13)+log(y(73))-log(y(20));
residual(44) = lhs - rhs;
lhs = y(79);
rhs = y(37)+y(77)-y(43);
residual(45) = lhs - rhs;
lhs = y(78);
rhs = y(43)+y(79);
residual(46) = lhs - rhs;
lhs = exp(y(80));
rhs = y(121)*(1+exp(y(134)))*exp(y(130));
residual(47) = lhs - rhs;
lhs = exp(y(82));
rhs = (1+exp(y(80)))*exp(y(74))/exp(y(21));
residual(48) = lhs - rhs;
lhs = exp(y(83));
rhs = (1+exp(y(80)))*exp(y(76))/exp(y(21));
residual(49) = lhs - rhs;
lhs = exp(y(81));
rhs = y(121)*(1+exp(y(135)))*exp(y(131));
residual(50) = lhs - rhs;
lhs = exp(y(84));
rhs = (1+exp(y(81)))*exp(y(77))/exp(y(22));
residual(51) = lhs - rhs;
lhs = exp(y(86));
rhs = (1+exp(y(81)))*exp(y(79))/exp(y(22));
residual(52) = lhs - rhs;
lhs = exp(y(85));
rhs = (1+exp(y(81)))*exp(y(78))/exp(y(22));
residual(53) = lhs - rhs;
lhs = y(87);
rhs = log(T(37))+params(32)*x(it_, 5);
residual(54) = lhs - rhs;
lhs = y(116);
rhs = params(32)*x(it_, 5)+log(T(38));
residual(55) = lhs - rhs;
lhs = y(88);
rhs = y(139)-y(71);
residual(56) = lhs - rhs;
lhs = y(117);
rhs = y(164)-y(71);
residual(57) = lhs - rhs;
lhs = y(26);
rhs = log(y(121));
residual(58) = lhs - rhs;
lhs = T(28)*y(109);
rhs = y(121)*y(125);
residual(59) = lhs - rhs;
lhs = exp((-2)*y(89));
rhs = T(28)*exp((-y(124)));
residual(60) = lhs - rhs;
lhs = exp((-3)*y(90));
rhs = T(28)*exp((-2)*y(140));
residual(61) = lhs - rhs;
lhs = exp((-4)*y(91));
rhs = T(28)*exp((-3)*y(141));
residual(62) = lhs - rhs;
lhs = exp((-5)*y(92));
rhs = T(28)*exp((-4)*y(142));
residual(63) = lhs - rhs;
lhs = exp((-6)*y(93));
rhs = T(28)*exp((-5)*y(143));
residual(64) = lhs - rhs;
lhs = exp((-7)*y(94));
rhs = T(28)*exp((-6)*y(144));
residual(65) = lhs - rhs;
lhs = exp((-8)*y(95));
rhs = T(28)*exp((-7)*y(145));
residual(66) = lhs - rhs;
lhs = exp((-9)*y(96));
rhs = T(28)*exp((-8)*y(146));
residual(67) = lhs - rhs;
lhs = exp((-10)*y(97));
rhs = T(28)*exp((-9)*y(147));
residual(68) = lhs - rhs;
lhs = exp((-11)*y(98));
rhs = T(28)*exp((-10)*y(148));
residual(69) = lhs - rhs;
lhs = exp((-12)*y(99));
rhs = T(28)*exp((-11)*y(149));
residual(70) = lhs - rhs;
lhs = exp((-13)*y(100));
rhs = T(28)*exp((-12)*y(150));
residual(71) = lhs - rhs;
lhs = exp((-14)*y(101));
rhs = T(28)*exp((-13)*y(151));
residual(72) = lhs - rhs;
lhs = exp((-15)*y(102));
rhs = T(28)*exp((-14)*y(152));
residual(73) = lhs - rhs;
lhs = exp((-16)*y(103));
rhs = T(28)*exp((-15)*y(153));
residual(74) = lhs - rhs;
lhs = exp((-17)*y(104));
rhs = T(28)*exp((-16)*y(154));
residual(75) = lhs - rhs;
lhs = exp((-18)*y(105));
rhs = T(28)*exp((-17)*y(155));
residual(76) = lhs - rhs;
lhs = exp((-19)*y(106));
rhs = T(28)*exp((-18)*y(156));
residual(77) = lhs - rhs;
lhs = exp((-20)*y(107));
rhs = T(28)*exp((-19)*y(157));
residual(78) = lhs - rhs;
lhs = y(108);
rhs = y(107)-y(38);
residual(79) = lhs - rhs;
lhs = y(53);
rhs = y(13)+log(y(29))-log(y(3));
residual(80) = lhs - rhs;
lhs = y(55);
rhs = y(13)+log(y(30))-log(y(4));
residual(81) = lhs - rhs;
lhs = y(56);
rhs = y(13)+log(y(50))-log(y(16));
residual(82) = lhs - rhs;
lhs = y(58);
rhs = y(13)+y(46)-y(12);
residual(83) = lhs - rhs;
lhs = y(59);
rhs = y(128);
residual(84) = lhs - rhs;
lhs = y(31);
rhs = T(42)^T(43);
residual(85) = lhs - rhs;
lhs = y(54);
rhs = y(13)+log(y(31))-log(y(5));
residual(86) = lhs - rhs;
lhs = y(57);
rhs = y(53)+y(41)-y(43);
residual(87) = lhs - rhs;
lhs = y(60);
rhs = y(37)+y(13)+log(y(28)+y(50)*y(40))-log(y(2)+y(10)*y(16))-y(43);
residual(88) = lhs - rhs;
lhs = y(61);
rhs = y(37)+y(13)+log(y(32))-log(y(6))-y(43);
residual(89) = lhs - rhs;
lhs = y(110);
rhs = y(133)+params(21)*y(158);
residual(90) = lhs - rhs;
lhs = y(111);
rhs = y(136)+params(21)*y(159);
residual(91) = lhs - rhs;
lhs = y(112);
rhs = y(132)+params(21)*y(160);
residual(92) = lhs - rhs;
lhs = y(113);
rhs = y(137)+params(21)*y(161);
residual(93) = lhs - rhs;
lhs = y(114);
rhs = y(71)+params(21)*y(162);
residual(94) = lhs - rhs;
lhs = y(115);
rhs = y(38)+params(21)*y(163);
residual(95) = lhs - rhs;
lhs = y(118);
rhs = y(138);
residual(96) = lhs - rhs;
lhs = y(119);
rhs = y(137);
residual(97) = lhs - rhs;

end
